/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * TelaPrincipal.java
 *
 * Created on Dec 25, 2011, 5:34:38 PM
 */
package br.ufrn.adurn.gui;

import br.ufrn.adurn.domain.Usuario;

/**
 *
 * @author Victor
 */
public class TelaPrincipal extends javax.swing.JFrame {

    //Usuario usuarioLogado;
    Usuario usuarioLogado = Usuario.getInstance();

    /** Creates new form TelaPrincipal */
    public TelaPrincipal() {

        initComponents();

        //this.usuarioLogado = usuario;
        if (usuarioLogado.isAdmin()) {
            ativarOpcoesAdmin();
        }
    }

    private void ativarOpcoesAdmin() {
        consignacaoButton.setEnabled(true);
        avancadoButton.setEnabled(true);
        cadastrarProfButton.setEnabled(true);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollBar1 = new javax.swing.JScrollBar();
        sairButton = new javax.swing.JButton();
        infoButton = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        nomeTextField = new javax.swing.JTextField();
        buscarButton = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        consignacaoButton = new javax.swing.JButton();
        etiquetasButton = new javax.swing.JButton();
        emailsButton = new javax.swing.JButton();
        avancadoButton = new javax.swing.JButton();
        cadastrarProfButton = new javax.swing.JButton();
        relatorioButton = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("SysADURN");

        sairButton.setIcon(new javax.swing.ImageIcon("C:\\Users\\Victor\\Documents\\NetBeansProjects\\SysADURN\\icons\\out.png")); // NOI18N
        sairButton.setText("Sair");
        sairButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                sairButtonActionPerformed(evt);
            }
        });

        infoButton.setIcon(new javax.swing.ImageIcon("C:\\Users\\Victor\\Documents\\NetBeansProjects\\SysADURN\\icons\\information.png")); // NOI18N
        infoButton.setText("Sobre");

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Caixa de pesquisa"));

        buscarButton.setIcon(new javax.swing.ImageIcon("C:\\Users\\Victor\\Documents\\NetBeansProjects\\SysADURN\\icons\\zoom.png")); // NOI18N
        buscarButton.setText("Buscar...");
        buscarButton.setFocusable(false);
        buscarButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buscarButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(nomeTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 504, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(buscarButton)
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(nomeTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 25, Short.MAX_VALUE)
                    .addComponent(buscarButton))
                .addContainerGap())
        );

        jPanel2Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {buscarButton, nomeTextField});

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        consignacaoButton.setIcon(new javax.swing.ImageIcon("C:\\Users\\Victor\\Documents\\NetBeansProjects\\SysADURN\\icons\\money_dollar.png")); // NOI18N
        consignacaoButton.setText("Consignação");
        consignacaoButton.setEnabled(false);

        etiquetasButton.setIcon(new javax.swing.ImageIcon("C:\\Users\\Victor\\Documents\\NetBeansProjects\\SysADURN\\icons\\email.png")); // NOI18N
        etiquetasButton.setText("Etiquetas");

        emailsButton.setIcon(new javax.swing.ImageIcon("C:\\Users\\Victor\\Documents\\NetBeansProjects\\SysADURN\\icons\\at-sign.gif")); // NOI18N
        emailsButton.setText("E-mails");

        avancadoButton.setIcon(new javax.swing.ImageIcon("C:\\Users\\Victor\\Documents\\NetBeansProjects\\SysADURN\\icons\\cog_go.png")); // NOI18N
        avancadoButton.setText("Avançado");
        avancadoButton.setEnabled(false);
        avancadoButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                avancadoButtonActionPerformed(evt);
            }
        });

        cadastrarProfButton.setIcon(new javax.swing.ImageIcon("C:\\Users\\Victor\\Documents\\NetBeansProjects\\SysADURN\\icons\\user_add.png")); // NOI18N
        cadastrarProfButton.setText("Cadastrar Prof.");
        cadastrarProfButton.setEnabled(false);
        cadastrarProfButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cadastrarProfButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(emailsButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(etiquetasButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cadastrarProfButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(consignacaoButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(avancadoButton)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {avancadoButton, consignacaoButton, emailsButton, etiquetasButton});

        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(emailsButton)
                    .addComponent(etiquetasButton)
                    .addComponent(cadastrarProfButton)
                    .addComponent(consignacaoButton)
                    .addComponent(avancadoButton))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        relatorioButton.setIcon(new javax.swing.ImageIcon("C:\\Users\\Victor\\Documents\\NetBeansProjects\\SysADURN\\icons\\chart_bar.png")); // NOI18N
        relatorioButton.setText("Relatório");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(sairButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(infoButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(relatorioButton)))
                .addContainerGap())
        );

        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {infoButton, relatorioButton, sairButton});

        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(relatorioButton)
                    .addComponent(infoButton)
                    .addComponent(sairButton))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void sairButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sairButtonActionPerformed
    // ENCERRAR CONEXAO COM O BD
    dispose();
}//GEN-LAST:event_sairButtonActionPerformed

private void buscarButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buscarButtonActionPerformed
    // TODO add your handling code here:
    TelaBuscar telaBuscar = new TelaBuscar(nomeTextField.getText());
    telaBuscar.setVisible(rootPaneCheckingEnabled);
}//GEN-LAST:event_buscarButtonActionPerformed

    private void avancadoButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_avancadoButtonActionPerformed
        new TelaAvancado().setVisible(true);
    }//GEN-LAST:event_avancadoButtonActionPerformed

    private void cadastrarProfButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cadastrarProfButtonActionPerformed
        new TelaCadastrarProfessor(usuarioLogado).setVisible(true);
    }//GEN-LAST:event_cadastrarProfButtonActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton avancadoButton;
    private javax.swing.JButton buscarButton;
    private javax.swing.JButton cadastrarProfButton;
    private javax.swing.JButton consignacaoButton;
    private javax.swing.JButton emailsButton;
    private javax.swing.JButton etiquetasButton;
    private javax.swing.JButton infoButton;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollBar jScrollBar1;
    private javax.swing.JTextField nomeTextField;
    private javax.swing.JButton relatorioButton;
    private javax.swing.JButton sairButton;
    // End of variables declaration//GEN-END:variables
}
